<template>
  <el-dialog :title="shopName" :visible.sync="dialogVisible" width="600px" :close-on-click-modal="false" center @close="close">
    <div v-loading="loading" class="qr-code" element-loading-text="加载中">
      <img :src="qrCodeUrl" alt>
      <!-- <a href="https://geekjc-img.geekjc.com/logo.png" download="logo.png">下载图片</a> -->
    </div>
    <span slot="footer" class="dialog-footer">
      <!-- <el-button size="small" round type="primary" @click="handleSubmit">下载二维码</el-button> -->
    </span>
  </el-dialog>
</template>

<script>
import { getShopPromoteQrCode } from '@/api/shop'
export default {
  data() {
    return {
      dialogVisible: false,
      loading: false,
      shopName: '',
      qrCodeUrl: ''
    }
  },
  methods: {
    open(row) {
      this.shopName = row.name
      this.getQrCode(row.id)
      this.show()
    },

    show() {
      this.dialogVisible = true
    },

    close() {},

    hide() {
      this.resolve = null
      this.reject = null
      this.dialogVisible = false
    },

    getQrCode(id) {
      this.loading = true
      getShopPromoteQrCode({ shopId: id })
        .then(res => {
          this.loading = false
          this.qrCodeUrl = res.data
        })
        .catch(err => {
          this.loading = false
        })
    },

    handleSubmit() {}
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .qr-code {
    margin: 0 auto;
    width: 250px;
    height: 250px;
  }
</style>
